using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Text;

namespace MindFair.HomeLeague.Bowling
{
    [Serializable]
    public class DeadlineExceededException : Exception
    {
        public DeadlineExceededException()
            : base("A deadline has been exceeded; view stack trace for details.")
        {
            _deadline = DateTime.MinValue;
        }

        public DeadlineExceededException(string message)
            : base(message)
        {
            _deadline = DateTime.MinValue;
        }
        public DeadlineExceededException(DateTime deadline, string message)
            : base(message)
        {
            _deadline = deadline;
        }

        public DeadlineExceededException(string message, Exception innerException)
            : base(message, innerException)
        {
            _deadline = DateTime.MinValue;
        }
        public DeadlineExceededException(DateTime deadline, string message, Exception innerException)
            : base(message, innerException)
        {
            _deadline = deadline;
        }

        [CoverageExclude]
        protected DeadlineExceededException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            if (info == null)
                throw new ArgumentNullException("info");
            _deadline = info.GetDateTime("_deadline");
        }

        private DateTime _deadline;
        public DateTime Deadline
        {
            get { return _deadline; }
        }

        [CoverageExclude]
        [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
                throw new ArgumentNullException("info");
            info.AddValue("_deadline", _deadline);
            base.GetObjectData(info, context);
        }
    }
}
